from marketdata import statistic
from mapper import Mapper
import logging


class NoHubCleaner(Mapper):
    CHILD = None

    def map(self,key):
    	solarSystemID = long(str(key.name())[6:15])
    	logging.info("Entity = %s, key = %s, ssID = %d" % (key.kind(),key.name(),solarSystemID))
    	if not solarSystemID in statistic.TradeHubs:
       	    ToDelete = [key]
       	    q = self.CHILD.all(keys_only = True)
       	    q.ancestor(key)
       	    q.order("__key__")
       	    ToDelete.extend(q)
       	    logging.info("ToDelete %d with key %s" % (len(ToDelete),str(key.name())))
            return ([],ToDelete)
        return([],[])
